package org.i1510.spider.utils.test;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;




public class Socket2Html { 
    		private URL url; 

			public Socket2Html() { 
			        try { 
			            URL url = new URL("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=joeone"); 
			            HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 
			            connection.setRequestMethod("POST"); 
			            connection.addRequestProperty("Accept-Charset",
			            "utf-8");
			            System.out.println(connection.getRequestMethod()); 
			            connection.setDoOutput(true); 
//			            PrintWriter out = new PrintWriter(connection.getOutputStream()); 
//			            String name = "name="+URLEncoder.encode("lixueling", "UTF-8");  
//			            String pass = "pass="+URLEncoder.encode("jiayou", "UTF-8"); 
//			            out.println(name+"&"+pass); 
//			            out.close(); 
			            BufferedReader in 
			                = new BufferedReader(new InputStreamReader(connection.getInputStream(),"utf-8")); 
			            String line; 
			            while ((line = in.readLine()) != null) { 
			                  System.out.println(line); 
			              } 
			            in.close(); 
			        } catch (Exception ex) { 
			            ex.printStackTrace(); 
			        } 
	        
	    } 


    
    public static void main(String[] args) { 
    	new Socket2Html();
//    	while(1==1){
//    		new Socket2Html(); 
//    	}
//    	new gFrame("Good Luck"); 
//new GFrame1("ss");
        // TODO code application logic here
    } 
}
   